package com.pos.action;

import com.opensymphony.xwork2.ActionSupport;
import com.pos.pojo.Users;
import com.pos.service.UserService;
import com.pos.service.impl.UserServiceImpl;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;

public class loginAction extends ActionSupport {
    private String userId;
    private String password;

   UserService userService;
    public String logins(){
        System.out.println(userId);
        Users user = userService.getUserById(userId);
        System.out.println(11111);
        if(user==null)
            return "fail";
        String dbpwd = user.getPassword();
        if(!dbpwd.equals(password))
            return "fail";
        System.out.println(11111);
        System.out.println(user.getRole().getRoleId());
        if(user.getRole().getRoleName().equals("waiter"))
            return "listDish_w";
        return "listDish";

    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public UserService getUserService() {
        return userService;
    }

    public void setUserService(UserService userService) {
        this.userService = userService;
    }
}
